package com.lizhen.behaviorpattern.chainpattern;

public abstract class AbstractLogger {
    public static int INFO = 1;
    public static int DEBUG = 2;
    public static int ERROR = 3;
    protected int level;
    protected AbstractLogger nextLogger;

    public AbstractLogger() {
    }

    public void setNextLogger(AbstractLogger nextLogger) {
        this.nextLogger = nextLogger;
    }

    public void logMessage(int level, String message) {
        if (this.level <= level) {
            this.write(message);
        }

        if (this.nextLogger != null) {
            this.nextLogger.logMessage(level, message);
        }

    }

    protected abstract void write(String var1);
}
